package com.control;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jdbc.BDManagement;


public class CargaDestinosCochesBoletos extends HttpServlet {
	private BDManagement bdm = new BDManagement();
	
	
	protected void procesaryCargarDatos(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		LinkedList<String> listaDeDestinos = new LinkedList<String>();
		ResultSet r = bdm.getAllUsuarios();
		while(r.next()){
			listaDeDestinos.add(r.getString(2));
		}
		request.setAttribute("listaDeDestinos", listaDeDestinos);
		this.getServletContext().getRequestDispatcher("/venderBoletos.jsp").forward(request, response);
	}
       


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			procesaryCargarDatos(request, response);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			procesaryCargarDatos(request, response);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
